package com.joysuch.wwyt.workflow.entity;

import com.joysuch.wwyt.core.support.AutoSetCommonFieldListener;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.hibernate.annotations.SQLDelete;
import org.hibernate.annotations.SQLDeleteAll;
import org.hibernate.annotations.Where;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;

import javax.persistence.*;
import java.time.LocalDateTime;

import static javax.persistence.GenerationType.IDENTITY;

/**
 * @Author ZhangDong
 * @Date 2020/12/17 9:24
 */
@Data
@Entity
@EntityListeners({ AuditingEntityListener.class, AutoSetCommonFieldListener.class })
@Table(name = "wwyt_workflow_rail_alarm_task")
@SQLDelete(sql = "update wwyt_workflow_rail_alarm_task set DELETE_FLAG = '1' where id= ?")
@SQLDeleteAll(sql = "update wwyt_workflow_rail_alarm_task set DELETE_FLAG = '1' where id= ?")
@Where(clause = "DELETE_FLAG = '0'")
public class WorkFlowRailAlarmTask {

    @Id
    @GeneratedValue(strategy = IDENTITY)
    @ApiModelProperty("主键id")
    private Long id;
    @ApiModelProperty("流程任务id")
    private Long taskId;
    @ApiModelProperty("流程任务id")
    private String uniqueId;
    @ApiModelProperty("状态: 0 初始状态; 1 已新增; 2 新增失败; 3 已删除; 4 删除失败")
    private Integer status = 0;
    @ApiModelProperty("传输数据json")
    private String data;
    @ApiModelProperty("开始时间即推送时间")
    private LocalDateTime startTime;
    @ApiModelProperty("结束时间即删除报警时间")
    private LocalDateTime endTime;

    //通用字段
    @org.springframework.data.annotation.CreatedBy
    @ApiModelProperty("创建人")
    private Long createBy;
    @org.springframework.data.annotation.CreatedDate
    @ApiModelProperty("创建时间")
    private LocalDateTime createTime;
    @org.springframework.data.annotation.LastModifiedBy
    @ApiModelProperty("更新人")
    private Long updateBy;
    @org.springframework.data.annotation.LastModifiedDate
    @ApiModelProperty("更新时间")
    private LocalDateTime updateTime;
    @ApiModelProperty("租户")
    private Long tenentId;
    @ApiModelProperty("组织机构代码")
    private String orgCode;
    @ApiModelProperty("删除标记")
    private String deleteFlag;
}
